package com.rankeiot.platform.domain;

import java.io.Serializable;
import java.util.Date;
import java.sql.Types;
import java.util.Map;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rankeiot.core.data.IScoped;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.sagacity.sqltoy.config.annotation.Entity;
import org.sagacity.sqltoy.config.annotation.Id;
import org.sagacity.sqltoy.config.annotation.Column;



/**
 * 用户
 * @author desire
 */
@Schema(description = "用户")
@Data
@Entity(tableName="t_user")
public class User implements Serializable, IScoped {

    @Schema(description = "ID")
    @Id(strategy = "identity")
    @NotNull
    @Column(name="id",length=20L,type=Types.INTEGER,nullable=false,autoIncrement = true)
    private Long id;

    @Schema(description = "用户名")
    @NotNull
    @Length(max=40)
    @Column(name="username",length=40L,type=Types.VARCHAR,nullable=false)
    private String username;

    @Schema(description = "密码")
    @NotNull
    @Length(max=128)
    @Column(name="password",length=128L,type=Types.VARCHAR,nullable=false)
    private String password;

    @Schema(description = "姓名")
    @Length(max=20)
    @Column(name="name",length=20L,type=Types.VARCHAR)
    private String name;

    @Schema(description = "部门编码")
    @Length(max=20)
    @Column(name="branch_sn",length=20L,type=Types.VARCHAR)
    private String branchSn;

    @Schema(description = "头像")
    @Length(max=255)
    @Column(name="avatar",length=255L,type=Types.VARCHAR)
    private String avatar;

    @Schema(description = "手机号")
    @Length(max=40)
    @Column(name="phone",length=40L,type=Types.VARCHAR)
    private String phone;

    @Schema(description = "启用")
    @Column(name="enable",length=1L,type=Types.TINYINT,defaultValue = "0")
    private Boolean enable;

    @Schema(description = "性别")
    @Length(max=1)
    @Column(name="gender",length=1L,type=Types.VARCHAR,defaultValue = "0")
    private String gender;

    @Schema(description = "创建人")
    @Length(max=40)
    @Column(name="create_user",length=40L,type=Types.VARCHAR)
    private String createUserId;

    @Schema(description = "最后登录IP")
    @Length(max=255)
    @Column(name="login_ip",length=255L,type=Types.VARCHAR)
    private String loginIp;

    @Schema(description = "最后登录时间")
    @Column(name="login_time",length=26L,type=Types.TIMESTAMP)
    private Date loginTime;

    @Schema(description = "记录创建时间")
    @Column(name="create_time",length=26L,type=Types.TIMESTAMP)
    private Date createTime;

    @Schema(description = "更新时间")
    @Column(name="update_time",length=26L,type=Types.TIMESTAMP)
    private Date updateTime;

    @Schema(description = "包含角色")
    //@Column(name="roles",length=65535L,type=Types.ARRAY)
    private Set<String> roles;
    @Schema(description = "附加属性")
    @Column(name="props",length=65535L,type=Types.VARCHAR)
    private Map<String,Object> props;

    /**
     * 用于查询的role
     */

    private String role;
    private String branchName;

    @JsonIgnore
    private String scope;
}
